namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _20200702003 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.PowerTrees", "KeShiZhiWu_id", "dbo.KeShiZhiWus");
            DropIndex("dbo.PowerTrees", new[] { "KeShiZhiWu_id" });
            CreateTable(
                "dbo.PowerTreeKeShiZhiWus",
                c => new
                    {
                        PowerTree_ptid = c.Int(nullable: false),
                        KeShiZhiWu_id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.PowerTree_ptid, t.KeShiZhiWu_id })
                .ForeignKey("dbo.PowerTrees", t => t.PowerTree_ptid, cascadeDelete: true)
                .ForeignKey("dbo.KeShiZhiWus", t => t.KeShiZhiWu_id, cascadeDelete: true)
                .Index(t => t.PowerTree_ptid)
                .Index(t => t.KeShiZhiWu_id);
            
            DropColumn("dbo.PowerTrees", "KeShiZhiWu_id");
        }
        
        public override void Down()
        {
            AddColumn("dbo.PowerTrees", "KeShiZhiWu_id", c => c.Int());
            DropForeignKey("dbo.PowerTreeKeShiZhiWus", "KeShiZhiWu_id", "dbo.KeShiZhiWus");
            DropForeignKey("dbo.PowerTreeKeShiZhiWus", "PowerTree_ptid", "dbo.PowerTrees");
            DropIndex("dbo.PowerTreeKeShiZhiWus", new[] { "KeShiZhiWu_id" });
            DropIndex("dbo.PowerTreeKeShiZhiWus", new[] { "PowerTree_ptid" });
            DropTable("dbo.PowerTreeKeShiZhiWus");
            CreateIndex("dbo.PowerTrees", "KeShiZhiWu_id");
            AddForeignKey("dbo.PowerTrees", "KeShiZhiWu_id", "dbo.KeShiZhiWus", "id");
        }
    }
}
